#include <string>
#include <iostream>
#include <sstream>
#include <stdio.h>
#include "hashtbl.h"
#include "EncodedStructs.h"


int main()
{
     
        HashTbl *tbl;

        class numbers
        {
                public:
                        int reg;
        };

        numbers *p;


        if(!(tbl=new HashTbl(16, NULL))) {
                fprintf(stderr, "ERROR: hashtbl_create() failed\n");
                exit(EXIT_FAILURE);
        }


        int reg=0;
        tbl->insert("$zero", &reg);
        p=(numbers *)tbl->get("$zero");
        if(!p) printf("No match\n");
        else printf("$reg: %d \n", p->reg);


        reg++;
        tbl->insert("$at", &reg);
        p=(numbers *)tbl->get("$at");
        if(!p) printf("No match\n");
        else printf("$at: %d \n", p->reg); 


	reg++;
        tbl->insert("$v0", &reg);
        p=(numbers *)tbl->get("$v0");
        if(!p) printf("No match\n");
        else printf("$v0: %d \n", p->reg); 


	reg++;
        tbl->insert("$v1", &reg);
        p=(numbers *)tbl->get("$v1");
        if(!p) printf("No match\n");
        else printf("$v1: %d \n", p->reg); 


	reg++;
        tbl->insert("$a0", &reg);
        p=(numbers *)tbl->get("$a0");
        if(!p) printf("No match\n");
        else printf("$a0: %d \n", p->reg); 

        reg++;
        tbl->insert("$a1", &reg);  
        p=(numbers *)tbl->get("$a1");  
        if(!p) printf("No match\n");   
        else printf("$a1: %d \n", p->reg); 

        reg++;
        tbl->insert("$a2", &reg);
        p=(numbers *)tbl->get("$a2");
        if(!p) printf("No match\n"); 

        reg++;
        tbl->insert("$a3", &reg);
        p=(numbers *)tbl->get("$a3");
        if(!p) printf("No match\n"); 

        reg++;
        tbl->insert("$t0", &reg);
        p=(numbers *)tbl->get("$t0");
        if(!p) printf("No match\n"); 

        reg++;
        tbl->insert("$t1", &reg);
        p=(numbers *)tbl->get("$t1");
        if(!p) printf("No match\n"); 

        reg++;
        tbl->insert("$t2", &reg);
        p=(numbers *)tbl->get("$t2");
        if(!p) printf("No match\n"); 

        reg++;
        tbl->insert("$t3", &reg);
        p=(numbers *)tbl->get("$t3");
        if(!p) printf("No match\n"); 

        reg++;
        tbl->insert("$t4", &reg);
        p=(numbers *)tbl->get("$t4");
        if(!p) printf("No match\n"); 
	printf("$t4: %d\n", p->reg);

        reg++;
        tbl->insert("$t5", &reg);
        p=(numbers *)tbl->get("$t5");
        if(!p) printf("No match\n"); 

        reg++;
        tbl->insert("$t6", &reg);
        p=(numbers *)tbl->get("$t6");
        if(!p) printf("No match\n");

	reg++;
        tbl->insert("$t7", &reg);
        p=(numbers *)tbl->get("$t7");
        if(!p) printf("No match\n"); 
 
        reg++;
        tbl->insert("$s0", &reg);
        p=(numbers *)tbl->get("$s0");
        if(!p) printf("No match\n"); 	

        reg++;
        tbl->insert("$s1", &reg);
        p=(numbers *)tbl->get("$s1");
        if(!p) printf("No match\n"); 

        reg++;
        tbl->insert("$s2", &reg);
        p=(numbers *)tbl->get("$s2");
        if(!p) printf("No match\n"); 

        reg++;
        tbl->insert("$s3", &reg);
        p=(numbers *)tbl->get("$s3");
        if(!p) printf("No match\n"); 

        reg++;
        tbl->insert("$s4", &reg);
        p=(numbers *)tbl->get("$s4");
        if(!p) printf("No match\n"); 

        reg++;
        tbl->insert("$s5", &reg);
        p=(numbers *)tbl->get("$s5");
        if(!p) printf("No match\n"); 

        reg++;
        tbl->insert("$s6", &reg);   
        p=(numbers *)tbl->get("$s6");
        if(!p) printf("No match\n");	

        reg++;
        tbl->insert("$s7", &reg);
        p=(numbers *)tbl->get("$s7");
        if(!p) printf("No match\n");

	reg++;
        tbl->insert("$t8", &reg);
        p=(numbers *)tbl->get("$t8");
        if(!p) printf("No match\n"); 

        reg++;
        tbl->insert("$t9", &reg);
        p=(numbers *)tbl->get("$t9");
        if(!p) printf("No match\n");  

        reg++;
        tbl->insert("$k0", &reg);
        p=(numbers *)tbl->get("$k0");
        if(!p) printf("No match\n"); 

        reg++;
        tbl->insert("$k1", &reg);
        p=(numbers *)tbl->get("$k1");
        if(!p) printf("No match\n"); 

        reg++;
        tbl->insert("$gp", &reg);
        p=(numbers *)tbl->get("$gp");
        if(!p) printf("No match\n"); 
	printf("$gp: %d\n", p->reg);	

        reg++;
        tbl->insert("$sp", &reg);
        p=(numbers *)tbl->get("$sp");
        if(!p) printf("No match\n"); 

        reg++;
        tbl->insert("$fp", &reg);
        p=(numbers *)tbl->get("$fp");
        if(!p) printf("No match\n"); 


        reg++;
        tbl->insert("$ra", &reg);
        p=(numbers *)tbl->get("$ra");
        if(!p) printf("No match\n"); 

        delete(tbl);
        return 0;
}
